<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{count}}</h1>
        <!-- prevent修饰符可以阻止默认事件,常见于form表单的submit事件 -->
        <button @contextmenu.prevent=" ">右键</button>

        
        <div @click="fn1">oclick1
            <div @click="fn2">oclick2</div>
        </div>

        <br>
        <!-- .stop修饰符阻止传播，就只出发当前点击事件 -->
        <div @click="fn1">oclick1
            <div @click.stop="fn2">oclick2</div>
        </div>
        <hr>
        <!-- .capture修饰符可以把事件传播改为捕获，由外向内 -->
        <div @click.capture="fn1">oclick1
            <div @click="fn2">oclick2</div>
        </div>
        <br>
        <hr>
        <!-- .self修饰符:当事件要被触发的时候e.target是否是自身,如果是在触发事件 -->
        <div @click.self="fn1">oclick1
            <div @click="fn2">oclick2</div>
        </div>
        <br><hr>
        <!-- .once修饰符:一次性事件 -->
        <div @click.once="fn1">oclick1
            <div @click="fn2">oclick2</div>
        </div>
        <hr>
        <input type="text" @keyup.13="fn1"> <br>
        <input type="text" @keyup.enter="fn2">
        <input type="text" @keyup.space="fn1">
        <input type="text" @keydown.tab="fn2">
        <input type="text" @keydown.esc="fn1">

    </div>
    <script>
        Vue.config.productionTip = false; 
        
        const vm =new Vue({
            el:'#app',
            data(){
                return{
                   count:0
                }
            },
            methods:{
                fn1(){
                    console.log("11111");
                },

                fn2(){
                    console.log("222222");
                }    
            }
        })

    </script>
</body>

</html>